/**
 * @title: RouteManagerController
 * @projectName mscloud
 * @Description TODO
 * @Author
 * @Date 2022/3/19 21:41
 */
package com.atguigu.springcloud.cloudsentinelgatewaydevelop.controller;

import com.atguigu.springcloud.cloudsentinelgatewaydevelop.bean.dto.RouteDefinitionDTO;
import com.atguigu.springcloud.cloudsentinelgatewaydevelop.service.impl.RouteBeanDefinitionLocatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.List;

@RestController
public class RouteManagerController {
    @Autowired
    RouteBeanDefinitionLocatorService routeBeanDefinitionLocatorService;
    @RequestMapping("saveRouteDefinition")
    public Mono<Boolean> saveRouteDefinition(@RequestBody RouteDefinitionDTO routeDefinitionDto){
        Mono<Boolean> ret = routeBeanDefinitionLocatorService.saveRouteDefinition(routeDefinitionDto);
        return ret;
    }
    @RequestMapping("getAllRouteDefinition")
    public Mono<List<RouteDefinitionDTO>> getAllRouteDefinition(int page,int size){
        return routeBeanDefinitionLocatorService.getAllRouteDefinition(page,size);
    }

    @RequestMapping("deleteRouteDefinition")
    public Mono<Boolean> deleteRouteDefinition(@RequestBody RouteDefinitionDTO routeDefinitionDto){
        return routeBeanDefinitionLocatorService.deleteRoute(routeDefinitionDto);
    }

    @RequestMapping("getAllRouteInMem")
    public Mono<List<String>> getAllRouteInMem(){
        return routeBeanDefinitionLocatorService.getAllRouteInMem();
    }

    @RequestMapping("getRouteByRouteID")
    public Mono<RouteDefinitionDTO> getRouteByRouteID(String routeId){
        return routeBeanDefinitionLocatorService.getRouteByRouteID(routeId);
    }
}
